home *** CD-ROM | disk | FTP | other *** search
- /* insertfw.eqed -- Insert equation into FinalWriter
- *
- * This script will insert the current equation into FinalWriter
- * It is based on a script made by David Shaffer.
- * It will save the current equation in Encapsulated PostScript
- * with an embedded equation, and insert it in FinalWriter.
- * If the current object has the same name, it will replaced by
- * the new one. See the manual for more details.
- *
- * It requires rexxreqtools.library
- */
-
- options results
-
- IF ~SHOW('p',"FINALW.1") THEN EXIT
-
- if ~show('l','rexxreqtools.library') then
- if ~addlib('rexxreqtools.library',0,-30,0) then EXIT
-
- /* Save old settings */
- GetOutput
- OldOutput=result
-
- GetName
- Name=result
- if Name = '' then do
- /* Get default directory name from FW*/
- address 'FINALW.1' status pathname
- defpath = result
- DivPos = max(lastpos(':',defpath),lastpos('/',defpath))+1
- defpath = left(defpath,DivPos-1)
- Name = rtfilerequest(defpath,,'Enter file name','Accept',,)
- if Name = '' then EXIT
- end
-
- /* Save equation and get boundingbox information! */
- SETOUTPUT PREVIEWPS EMBEDDED
- Save Name
- bb = result
-
- /* Restore old settings */
- SetOutput SUBWORD(OldOutput,1,1) SUBWORD(OldOutput,2,1)
-
- /* Now on to final writer */
- ADDRESS "FINALW.1"
-
- status page "Insert"
- page = result
- setmeasure micropoints
-
- /* Now get info about the currently selected object */
- currentobject
- co = result
- ot = ''
- xoffset = 0
- yoffset = 0
- if co ~= 0 then
- do
- getobjecttitle
- ot = result
- if ot = name then
- do
- getobjectparams co textflow flowdist linked display
- objparams = result
- getobjectcoords co
- objcoords = result
- page = word(objcoords,1)
- xoffset = word(objcoords,2)
- yoffset = word(objcoords,3)
- deleteobject co
- end
- end
-
- /* -- convert to micropoints and strip off decimals */
- bbmp = ''
- do i = 1 to 4
- val = word(bb,i)
- if lastpos('.',val) ~= 0 then val = left(val,lastpos('.',val)-1)
- val = val * 10
- if i = 1 then val = val + xoffset
- if i = 2 then val = val + yoffset
- bbmp = bbmp || ' ' || val
- end
-
- /* Insert the image. */
-
- IMPORTPREFS DISPLAY PREVIEW TEXTFLOW NONE LINKED NO
-
- INSERTIMAGE name POSITION page bbmp
- currentobject
- co = result
-
- if name ~= '' then
- do
- setobjecttitle co name
- end
-
- SCREENTOFRONT
-
- REDRAW
-
-
-